package org.zxp.javacheck.keywords;

import org.junit.Test;

/**
 * @program: effectiveJava
 * @description: instanceof测试
 * @author: X-Pacific zhang
 * @create: 2019-08-20 13:35
 **/
public class InstanceofTest {

    @Test
    public void testInstanceof(){
        Object obj = 1;
        System.out.println(obj instanceof Integer);//true

        Object obj2 = new Object();
        InstanceofTest obj3 = new InstanceofTest();
        Object obj4 = new InstanceofTest();
        System.out.println(obj3 instanceof Object);//true
        System.out.println(obj2 instanceof Integer);//false
        System.out.println(obj4 instanceof Object);//true 一般不会这么写
        System.out.println(obj4 instanceof InstanceofTest);//true 一般这么写
    }
}
